﻿using System;
using System.Collections.Generic;
using System.Text;

namespace com.lover.astd.common.model.battle
{
    public class Npc : AsObject, IComparable<Npc>, IComparable
    {
        private bool _attack = false;
        /// <summary>
        /// 是否可以攻打
        /// </summary>
        public bool Attack
        {
            get { return _attack; }
            set { _attack = value; }
        }
        private int _type = 0;
        /// <summary>
        /// 普通/精英/主将
        /// </summary>
        public int Type
        {
            get { return _type; }
            set { _type = value; }
        }
        private string _itemName = "";
        /// <summary>
        /// 掉落装备
        /// </summary>
        public string ItemName
        {
            get { return _itemName; }
            set 
            {
                if (value == null || value.Equals("")) return;
                _itemName = value;
                _itemNamePure = _itemName.Substring(0, _itemName.IndexOf("（"));
                if (_itemName.IndexOf("小概率") >= 0) _itemRatioType = 1;
                else if (_itemName.IndexOf("大概率") >= 0) _itemRatioType = 2;
                else _itemRatioType = 0;
            }
        }
        private string _itemNamePure = "";
        public string ItemNamePure { get { return _itemNamePure; } }
        private int _itemRatioType = 0;
        /// <summary>
        /// 0=无, 1=小概率, 2=大概率
        /// </summary>
        public int ItemRatioType
        {
            get { return _itemRatioType; }
        }
        private string _itemColor = "#ffffff";
        /// <summary>
        /// 掉落装备颜色
        /// </summary>
        public string ItemColor
        {
            get { return _itemColor; }
            set { _itemColor = value; }
        }
        /// <summary>
        /// 阵型
        /// </summary>
        private string _formation = "不变阵";

        public string Formation
        {
            get { return _formation; }
            set { _formation = value; }
        }
        public string ItemDesc
        {
            get { return String.Format("{0} {1}", _name, _itemName); }
        }

        #region IComparable<Npc> 成员

        public int CompareTo(Npc other)
        {
            if (Id > other.Id) return -1;
            else if (Id < other.Id) return 1;
            else return 0;
        }

        #endregion

        #region IComparable 成员

        public int CompareTo(object obj)
        {
            Npc other = obj as Npc;
            if (other == null) return 0;
            if (Id > other.Id) return -1;
            else if (Id < other.Id) return 1;
            else return 0;
        }

        #endregion
    }
}
